﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace rambla.raws.rats
{
    [XmlRoot(Namespace = "http://rambla.be/raws/ns-metadata/1.0", ElementName = "params")]
    public class transcFile
    {
        ///<summary>
        ///filename of the transc instance on the RATS server
        ///</summary>
        [XmlElement(IsNullable = true)]
        public string filename;

        ///<summary>
        ///time at which the file was (over)written
        ///</summary>
        [XmlElement(IsNullable = true)]
        public string updated;
     }

    public class transcFiles
    {
        private ratsConnection conn;

        internal transcFiles(ratsConnection conn)
        {
            this.conn = conn;
        }

        public transcFile[] items
        {
            get
            {
                return conn.getObjects<transcFile>("/transc/");
            }
        }

        public void deleteItem(transcFile item)
        {
            conn.deleteObject("/transc/" + conn.Credentials.UserName + "/" + item.filename + "/");
        }

        public byte[] downloadItem(string filename)
        {
            return conn.downloadFile("/transc/media/" + conn.Credentials.UserName + "/" + filename + "/");
        }

        public transcFile getItem(string filename)
        {
            return conn.getObject<transcFile>("/transc/" + conn.Credentials.UserName + "/" + filename + "/");
        }
    }
}